﻿using Alphacat.Controller;
using Alphacat.Model;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Alphacat
{
    public partial class TaskForm : Form
    {
        

        public TaskForm()
        {
            InitializeComponent();
        }
        private WXService wxs;
        private TaskWork tw;
        private void TaskForm_Load(object sender, EventArgs e)
        {
            this.wxs = new WXService();
            this.tw = new TaskWork(this.wxs);
            DoWxInit();
        }

        public void DoWxInit()
        {
            ((Action)delegate ()
            {
                JObject init_result = this.wxs.WxInit();  //初始化
                //Console.WriteLine(init_result);
                if (init_result != null)
                {
                    this.BeginInvoke((Action)delegate ()
                    {
                        this.tw.StartDoWork();
                    });

                }
                


            }).BeginInvoke(null, null);
        }

        private void TaskForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            tw.StopWork();
        }
    }
}
